import { _decorator, instantiate, Prefab, Node } from 'cc';
const { ccclass, property } = _decorator;

import { bdlMgr } from "../../../Script/Manager/BundleManager_S";
import ShuZiHuaRongDao_Block from "./ShuZiHuaRongDao_Block";
import { ShuZiHuaRongDao_GameData } from "./ShuZiHuaRongDao_GameData";
import { ShuZiHuaRongDao_GameManager } from "./ShuZiHuaRongDao_GameManager";

@ccclass('ShuZiHuaRongDaoGameFunction')
export default class ShuZiHuaRongDao_GameFunction {
    //    /** 创建牌组 */
    static async CreateBlock(_col: number, _row: number, _point: number) {
        const prefab = await bdlMgr.getRes<Prefab>(`ShuZiHuaRongDao_Prefab`, `ShuZiHuaRongDao_Block`, Prefab);
        const node: Node = instantiate(prefab);
        const block: ShuZiHuaRongDao_Block = node.getComponent(ShuZiHuaRongDao_Block);
        ShuZiHuaRongDao_GameManager.Instance.Root_block.addChild(node);
        block.init(_col, _row, _point);
        return block;
    }

    static GetBlock(_col: number, _row: number) {
        return ShuZiHuaRongDao_GameData.arrBlocks.find(e => e.col == _col && e.row == _row);
    }
}

// // /** 调试 */
window["ShuZiHuaRongDao_GameFunction"] = ShuZiHuaRongDao_GameFunction;